package com.turkline.CatchMePolygon;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;

import com.badlogic.androidgames.framework.FileIO;
import com.badlogic.androidgames.framework.impl.GLGame;

import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
public class XmlManager
{
	FileIO fileIO;
	public List<Element> XML_DATA;
	
	public XmlManager(GLGame glGame, String fileName) 
	{
		XML_DATA = new ArrayList<Element>();
		this.fileIO = glGame.getFileIO(); 
		InputStream in = null;
		  try 
		  {
			  in = fileIO.readAsset(fileName);
			DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
			DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
			Document doc = dBuilder.parse(in);
			doc.getDocumentElement().normalize();
	 
			NodeList nList = doc.getElementsByTagName("char");
			
			int uzunluk = nList.getLength();
			for (int i = 0; i<uzunluk ; i++)
			{
				XML_DATA.add((Element)nList.item(i));
			}
			
		  } 
		  catch (Exception e) 
		  {
			e.printStackTrace();
		  }
	  }
}
